/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-10-19
*/
package com.rzico.business.controller.admin;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rzico.annotation.Log;
import com.rzico.base.BaseController;
import com.rzico.base.CommResult;
import com.rzico.entity.Filter;
import com.rzico.entity.Pageable;
import com.rzico.entity.PageResult;
import com.rzico.business.entity.GcxxInfo;
import com.rzico.business.service.GcxxInfoService;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.Api;
import com.rzico.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;

/**
 * 过车信息控制层
 *
 * @author Rzico Boot
 * @version 1.0
 * @date 2020-10-19
 */
@Api(description = "过车信息接口")
@RestController
@RequestMapping("/admin/gcxxInfo")
public class GcxxInfoController extends BaseController {

    @Autowired
    private GcxxInfoService gcxxInfoService;

    /**
     * 分页查询过车信息
     *
     * @return
    */
    @ApiOperation("分页查询过车信息")
    @GetMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "hphm", value = "车牌号码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "ksrq", value = "开始日期", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "jsrq", value = "结束日期", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "kssj", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "jssj", value = "结束时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "clls", value = "车辆类型", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "gccs", value = "过车次数", dataType = "Integer", paramType = "query"),
    })
    public CommResult<GcxxInfo> list(String hphm,String ksrq,String jsrq,String kssj,String jssj,String clls,Integer gccs, Pageable pageable) {
        Map<String, Object> params = new HashMap<String, Object>();
        params = buildSortField(params, pageable);
        if (hphm!=null){
           params.put("hphm", hphm);
        }
        if (ksrq!=null){
            params.put("ksrq", ksrq);
        }
        if (jsrq!=null){
            params.put("jsrq", jsrq);
        }
        if (kssj!=null){
            params.put("kssj", kssj);
        }
        if (jssj!=null){
            params.put("jssj", jssj);
        }
        if (clls!=null){
            params.put("clls", clls);
        }
        if (gccs!=null){
            params.put("gccs", gccs);
        }

        Page<Object> startPage = PageHelper.startPage(pageable.getPageNum(), pageable.getPageSize());
        List<GcxxInfo> list = gcxxInfoService.selectList(params);
        PageResult<GcxxInfo> pageResult = new PageResult<GcxxInfo>(list, startPage.getTotal(), pageable);
        return CommResult.success(pageResult);
    }

    /**
     * 查询单条过车信息
     *
     * @return
    */
    @ApiOperation("查询单条过车信息")
    @GetMapping("/find/{id}")
    public CommResult<GcxxInfo> find(@PathVariable String id) {
        GcxxInfo result = gcxxInfoService.selectByPrimaryKey(id);

        Map<String,Object> data = new HashMap<>();
        data.put("gcxxInfo",result);
        return CommResult.success(data);

    }


}
